Skip to content

Conversation

@mikicvi-SAP
Copy link
Contributor

@mikicvi-SAP mikicvi-SAP commented Oct 10, 2025

#3718

  • Check if the system has credentials stored; if not, don't save
    • Log in end phase of the Fiori generator if not saving
  • Show the message attached to the system selection if the system does not have credentials stored
  • Show a warning message attached to the password input about the OS's password storage policy
  • If the username is saved with a system with incorrect credentials, pre-fill the username for reauth

@mikicvi-SAP mikicvi-SAP self-assigned this Oct 10, 2025
@changeset-bot
Copy link

changeset-bot bot commented Oct 10, 2025

🦋 Changeset detected

Latest commit: 7960995

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@sap-ux/odata-service-inquirer Minor
@sap-ux/fiori-app-sub-generator Patch
@sap-ux/deploy-config-sub-generator Patch
@sap-ux/repo-app-import-sub-generator Patch
@sap-ux/ui-service-inquirer Patch
@sap-ux/ui-service-sub-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mikicvi-SAP mikicvi-SAP marked this pull request as ready for review October 10, 2025 10:45
@mikicvi-SAP mikicvi-SAP requested a review from a team as a code owner October 10, 2025 10:45
Copy link
Contributor

@lfindlaysap lfindlaysap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikicvi-SAP, here are my suggestions.

// No need to await, we cannot recover anyway
// eslint-disable-next-line @typescript-eslint/no-floating-promises
storeService.write(service.backendSystem);
} else if (service.backendSystem?.newOrUpdated === false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this condition should be inside (service.backendSystem && hostEnv !== hostEnvironment.bas) otherwise it will always log, even on bas.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense - thank you. Committed, with an additional check, as discussed.

@mikicvi-SAP mikicvi-SAP marked this pull request as draft October 17, 2025 09:22
service.backendSystem &&
hostEnv !== hostEnvironment.bas &&
service.backendSystem.newOrUpdated &&
!service.backendSystem.temporaryCredentials
Copy link
Contributor

@IainSAP IainSAP Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not remove the credentials from the PromptState.odataService.backendSystem object before returning (wherever we determine this) - so we dont need this extra logic in multiple places? I dont recall why we need this extra property temporaryCredentials?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could do it with just newOrUpdated, actually, without the temporaryCredentials.

);
(backendSystem as BackendSystemSelection).hasStoredCredentials = true;
return true;
} else if (errorType === ERROR_TYPE.AUTH && !hasStoredCredentials) {
Copy link
Contributor

@IainSAP IainSAP Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this condition? Regardless of having creds or auth fails and the user will have to input credentials.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed - leftover from testing something during dev, will remove it - thanks for spotting!

systemChoices = await Promise.all(
backendSystems.map(async (system) => {
// Check if the system has stored credentials by reading it with sensitive data
const systemWithCredentials = await new SystemService(LoggerHelper.logger).read(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is reading every system from secure store? We went to some effort to avoid this!

@sonarqubecloud
Copy link

@mikicvi-SAP mikicvi-SAP marked this pull request as ready for review October 23, 2025 09:08
const selectedSystem = answers?.[promptNames.systemSelection] as SystemSelectionAnswerType;
if (selectedSystem?.type === 'backendSystem') {
const selectedBackendSystem = selectedSystem.system as BackendSystem;
if (selectedBackendSystem?.userDisplayName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why check for display name here? I dont think this is related to the username.

return valResult;
},
additionalMessages: (password: string, answers: T) => {
if (PromptState.odataService.connectedSystem?.backendSystem?.newOrUpdated) {
Copy link
Contributor

@IainSAP IainSAP Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a lower priority that the cert errors (the condition should be evaluated after error conditions)

);
} else if (backendSystem.authenticationType === 'basic' || !backendSystem.authenticationType) {
const hasStoredCredentials = !!(backendSystem.username && backendSystem.password);
PromptState.hasStoredCredentials = hasStoredCredentials;
Copy link
Contributor

@IainSAP IainSAP Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure we should be maintaining a specific system info at the root level without context. Can we instead update the locally cached backend system (selected system actually) that is selected with updateCredentials boolean property that is set based on some criteria (existence of credentials or a property of the stored system in future marked as do not store creds).

const selectedBackendSystem = selectedSystem.system as BackendSystem;
if (selectedBackendSystem?.userDisplayName) {
// Read system with credentials to get the stored username, since we won't assume that displayName = username
const systemWithCredentials = await new SystemService(LoggerHelper.logger).read(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can avoid a second read here.

typeof backendSystem.username === 'string' &&
typeof backendSystem.password === 'string'
) {
if (errorType === ERROR_TYPE.AUTH) {
Copy link
Contributor

@IainSAP IainSAP Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldnt be validating if there are no credentials to validate hence the conditions that have been removed? Note that this code is also used by new system flows probably and so these conditions are relevant in those cases

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was meant to check with hasStoredCredentials from above, which would be valid at that point. I missed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants